#include <libavformat/avio.h>
#include <libavformat/avformat.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define BUF_SIZE 1024 * 1024 * 2

int read_packet(int *fd, uint8_t *buf, int buf_size)
{
    int ret = recv(*fd, *buf, sizeof(buf_size), 0);
    return AVERROR(EAGAIN);
}

int main(int argc, char const *argv[])
{

    AVIOContext *pb = NULL;
    AVInputFormat *piFmt = NULL;
    AVInputFormat *pFmt = NULL;

    int fd = socket(AF_INET, SOCK_STREAM, 0);

    uint8_t *buf = (uint8_t *)av_mallocz(sizeof(uint8_t) * BUF_SIZE);

    struct sockaddr_in my_addr;

    //bind(fd,)

    pb = avio_alloc_context(buf, BUF_SIZE, 1, &fd, read_packet, NULL, NULL);

    av_probe_input_buffer2(pb, &piFmt, "", NULL, 0, 0);

    printf("finish \n");

    return 0;
}
